﻿using Pay.DTO;
using Pay.TO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Pay.H5.Models {
    /// <summary>
    /// 商城支付请求报文
    /// </summary>
    public class mall_model : head_req {
        public mall_model() {
            orders = new List<order_create_model>();
        }
        /// <summary>
        /// 支付单号
        /// </summary>
        public string order_no { get; set; }
        /// <summary>
        /// 订单金额,分为单位
        /// </summary>
        public string tran_amount { get; set; }
        /// <summary>
        /// 商品描述
        /// </summary>
        public string body { get; set; }
        /// <summary>
        /// 商品的标题，该参数最长为 32 个  字符，京东支付、网关支付、快捷支付、QQ钱包为必填
        /// </summary>
        public string subject { get; set; }
        /// <summary>
        /// 支付成功后服务器回调该地址
        /// </summary>
        public string notify { get; set; }
		/// <summary>
		/// h5同步通知
		/// </summary>
		public string front_notify { get; set; }
        /// <summary>
        /// 通道
        /// </summary>
        public PayChannel pay_channel { get; set; }
        /// <summary>
        /// 支付方式：微信扫码支付WXPAY_QR，支付宝扫码支付ALIPAY_QR，京东扫码支付JDPAY_QR,银联扫码支付UNIONPAY_QR，QQ钱包扫码支付QQ_QR，
        /// 微信付款码支付WXPAY_MICRO,支付宝款码支付ALIPAY_MICRO,
        /// 微信APP支付WXPAY_APP,支付宝APP支付ALIPAY_APP,
        /// 微信公众账号支付WXPAY_JS,支付宝服务窗支付ALIPAY_JS,
        /// </summary>
        public string pay_code { get; set; }
        /// <summary>
        /// 结算方式：T0,T1
        /// </summary>
        public string settle_type { get; set; }
        /// <summary>
        /// 微信公众账号支付：子商户公众号下关注的用户openid
        /// </summary>
        public string openid { get; set; }
        /// <summary>
        /// 支付宝、微信APP、微信公众账号支付创建应用所生成的AppID
        /// </summary>
        public string appid { get; set; }
        /// <summary>
        /// 订单信息
        /// </summary>
        public List<order_create_model> orders { get; set; }
        /// <summary>
        /// 配送方式 1：物流，2：到店拿货，3：自提，4：无配送
        /// </summary>
        public int shipping_type { get; set; }
        /// <summary>
        /// 收货地址
        /// </summary>
        public shipping_address shipping { get; set; }
        /// <summary>
        /// 1:app,2:h5
        /// </summary>
        public int req_method {
            get {
                return 2;
            }
        }
    }
    [Serializable]
    public class shipping_address {
        /// <summary>
        /// 交易号
        /// </summary>
       
        public string order_no { get; set; }
        /// <summary>
        /// 收货人
        /// </summary>
       
        public string ship_to { get; set; }
        /// <summary>
        /// 收货人电话
        /// </summary>
       
        public string phone { get; set; }
        /// <summary>
        /// 省id
        /// </summary>
        public long province_id { get; set; }
        /// <summary>
        /// 城市id
        /// </summary>
        public long city_id { get; set; }
        /// <summary>
        /// 县或区ID
        /// </summary>
        public long? area_id { get; set; }
        /// <summary>
        /// 全名的收货地址
        /// </summary>
        public string region_name { get; set; }
        /// <summary>
        /// 收货具体街道信息
        /// </summary>
      
        public string address { get; set; }
        /// <summary>
		/// 身份证号码
		/// </summary>
		public string id_card { get; set; }
        /// <summary>
		/// 真实姓名
		/// </summary>
		public string real_name { get; set; }
    }
    /// <summary>
    /// 创建订单的请求
    /// </summary>
    [Serializable]
    public class order_create_model {
        /// <summary>
        /// 初始化对象
        /// </summary>
        public order_create_model() {
            order_items = new List<order_item_model>();
            binds = new List<bind_merchant_item>();
        }
        /// <summary>
        /// 单号
        /// </summary>
        public string order_no { get; set; }
        /// <summary>
        /// 卖家编号
        /// </summary>
        public string merchant_no { get; set; }
        /// <summary>
        /// 优惠名称：折扣
        /// </summary>
        public string discount_name { get; set; }
        /// <summary>
        /// 优惠金额：折扣金额
        /// </summary>
        public decimal discount_amount { get; set; }
        /// <summary>
        /// 分销id
        /// </summary>
        public long? distribution_id {
            get; set;
        }
        /// <summary>
        /// 运费
        /// </summary>
        public decimal freight { get; set; }
		/// <summary>
		/// 税费
		/// </summary>
		public decimal tax { get; set; }
        /// <summary>
        /// 抵扣积分金额
        /// </summary>
        public decimal integral_discount { get; set; }
        /// <summary>
        /// 应付金额=订单金额-优惠-抵扣积分金额(要和API后台计算做验证)
        /// </summary>
        public decimal pay_amount { get; set; }
        /// <summary>
        /// 卖家手续费比例
        /// </summary>
        public decimal fee { get; set; }
        /// <summary>
        /// 卖家手续费
        /// </summary>
        public decimal fee_amount { get; set; }
        /// <summary>
        /// 订单金额分配集合，可空,如果是时代云商的会积分消费，此时金额中会有负数，是减使用着的冻结金额并加到卖家实收金额里
        /// </summary>
        public List<bind_merchant_item> binds { get; set; }
        /// <summary>
        /// 订单明细
        /// </summary>
        public List<order_item_model> order_items { get; set; }
    }

    /// <summary>
    /// 
    /// </summary>
    [Serializable]
    public class order_item_model {
        public order_item_model() {
            body = new Dictionary<string, object>();
        }
        /// <summary>
        /// 产品id，必须是同一家供应商的商品，不然提交会报错
        /// </summary>
        public long product_id { get; set; }
        /// <summary>
        /// 购买数量
        /// </summary>
        public int quantity { get; set; }
        /// <summary>
        /// 商品名称
        /// </summary>
        public string product_name { get; set; }
        /// <summary>
        /// 缩略图
        /// </summary>
        public string thumbnails_url { get; set; }
        /// <summary>
        /// 规格名称
        /// </summary>
        public string sku_name { get; set; }
        /// <summary>
        /// 规格路径
        /// </summary>
        public string sku_path { get; set; }
        /// <summary>
        /// 单价
        /// </summary>
        public decimal unit_price { get; set; }
        /// <summary>
        /// 市场价格
        /// </summary>
        public decimal market_price { get; set; }
        /// <summary>
        /// 抵扣积分
        /// </summary>
        public int integral { get; set; }
        /// <summary>
        /// 积分抵扣比例：在APP里直接购买或购买车里购买时，需要确认订单，此时会由云端返回比例
        /// </summary>
        public decimal integral_rate { get; set; }
        /// <summary>
        /// 扩展内容
        /// </summary>
        public Dictionary<string, object> body { get; set; }
    }

    /// <summary>
    /// 商城支付响应报文
    /// </summary>
    public class mall_result : result_base {
        /// <summary>
        /// 二维码串:交易类型为WXPAY_QR、ALIPAY_QR时有返回
        /// </summary>
        public string code_url { get; set; }
        /// <summary>
        /// 以下交易类型时有返回WXPAY_APP(WXPAY_APP返回json字符串组成，用户根据返回参数直接调用微信sdk进行支付)
        /// </summary>
        public string pay_info { get; set; }
        /// <summary>
        /// 商户订单号
        /// </summary>
        public string order_no { get; set; }
        /// <summary>
        /// 支付渠道返回的订单号
        /// </summary>
        public string transaction_no { get; set; }
        /// <summary>
        /// 是否调起支付
        /// </summary>
        public bool is_open { get; set; }
    }
}